package com.zivwu.demo;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.orhanobut.logger.Logger;
import com.zivwu.mvp.pick.PhotoPicker;
import com.zivwu.mvp.pick.RequestCode;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        findViewById(R.id.btn_select_one_without_preview)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        PhotoPicker.builder()
                                .setPhotoCount(1)
                                .closePreviewPhoto()
                                .start(MainActivity.this);
                    }
                });
    }



    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (RequestCode.getMode(requestCode) == RequestCode.CAMERA && RequestCode.getCode(requestCode) == PhotoPicker.REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK) {

            }
        } else if (RequestCode.getMode(requestCode) == RequestCode.ALBUM && RequestCode.getCode(requestCode) == PhotoPicker.REQUEST_CODE) {
            if (resultCode == Activity.RESULT_OK) {
                ArrayList<String> stringArrayList = data.getExtras().getStringArrayList(PhotoPicker.KEY_SELECTED_PHOTOS);
                if (stringArrayList != null && stringArrayList.size() > 0) {
                    Logger.d("s");
                }
            }
        }
    }
}
